<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        var obj = {
            id: 1,
            name: '小米',
            price: 1000
        }
        //Object.keys 获取对象身上所有属性
        var arr = Object.keys(obj)
        // console.log(arr);

        // Object.defineProperty  定义新属性或修改原有的属性       
        Object.defineProperty(obj, 'id', {
            // 不允许修改
            writable: false
        })
        Object.defineProperty(obj, 'num', {
            value: 1000,
            enumerable: false
        })
        Object.defineProperty(obj, 'price', {
            value: 1099
        })
        Object.defineProperty(obj, 'address', {
            value: '中国山东找蓝翔',
            writable: false,
            // enumerable如果值为false就不允许遍历
            enumerable: true,
            //configurable 如果为false 则不允许删除这个属性 默认为false
            configurable: true
        })
        console.log(obj);
        console.log(Object.keys(obj));
    </script>
</body>

</html>